package com.lei.eduservice.controller;


import com.lei.eduservice.entity.subject.OneSubject;
import com.lei.eduservice.service.EduSubjectService;
import com.lei.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author 熊磊
 * @since 2020-06-03
 */
@RestController
@RequestMapping("/edu/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;

    //根据上传过来的excel文件添加课程分类

    @PostMapping("/addSubject")
    public Result addSubject(MultipartFile file){
        //
        HashMap map = eduSubjectService.saveSubject(file, eduSubjectService);

        return Result.ok().data(map);
    }

    //获取课程分类列表
    @GetMapping("/subjectList")
    public Result subjectList(){
        //带有一级分类和二级分类
        List<OneSubject> list = eduSubjectService.subjectList();
        return Result.ok().data("list",list);
    }


}

